import pymysql
from ..database import connect_to_database, close_database_connection

async def update_message(ID, name, gender, age, weight, height):
    db, ssh_tunnel = connect_to_database()
    cursor = db.cursor(cursor=pymysql.cursors.DictCursor)
    sql = "UPDATE message SET name = %s, gender = %s, age = %s, weight = %s, height = %s WHERE id = %s"
    try:
        cursor.execute(sql, (name, gender, age, weight, height, ID))
        uploadSucceed = True
        db.commit()
    except Exception as e:
        print(e)
        uploadSucceed = False
        db.rollback()
    cursor.close()
    close_database_connection(db, ssh_tunnel)
    return uploadSucceed
